<?php

class Loguin extends CI_Controller{
    
    function __construct() {
        parent::__construct();


        $this->load->helper('form');
        $this->load->library('form_validation');
    }
    
    function index(){
        $data['main_content'] = 'loguin';
        $data['title'] = 'Login Usuario';
        $data['texto_cabecera'] = 'Loguin usuarios  ';
        $this->load->view('includes/template',$data);
    }
 
    function logued(){
        
$this->form_validation->set_rules('username', 'nombre de usuario', 'required|trim|min_length[5]|callback__verificar_usuario'); //trim sacar espacios- str-- pasar a mayusculas
$this->form_validation->set_rules('password', 'contraseña', 'required|md5'); 
$this->form_validation->set_message('required', 'Este campo es requerido');
$this->form_validation->set_message('min_length', 'Minimo 5 caracteres');
$this->form_validation->set_message('_verificar_usuario', 'El usuario ya se encuentra');
     if ($this->form_validation->run() == FALSE)
		{
			$this->index();
		}
		else
		{
                    echo $this->input->post('password');
		}
	}
    
    
        function _verificar_usuario($value){
            if($value='hola5'){
                return false;
            }
            else{
                return true;
            }
        }
        
        
}
?>
